# Maintainer: Morten Linderud <foxboron@archlinux.org>

pkgname=python-pydocstyle
pkgver=6.3.0
pkgrel=3
pkgdesc="Docstring style checker"
arch=("any")
url="http://www.pydocstyle.org/"
license=("MIT")
depends=("python-snowballstemmer")
makedepends=("python-build" "python-installer" "python-poetry-core")
checkdepends=("python-pytest" "python-pytest-runner" "python-pip" "python-snowballstemmer")
source=("$pkgname-$pkgver.tar.gz::https://github.com/PyCQA/pydocstyle/archive/${pkgver}.tar.gz")
sha256sums=('29ed0e8b1abe5f4590132f456b6f9cbf0866b89fabf836bc9474fde706e2e13e')

prepare() {
    cd "pydocstyle-${pkgver}"
    # Fix version number in metadata
    sed -e "s|^version = .*|version = \"$pkgver\"|" -i pyproject.toml
}

build() {
    cd "pydocstyle-${pkgver}"
    python -m build --wheel --no-isolation
}

check() {
    cd "pydocstyle-${pkgver}"
    PYTHONPATH="$PWD"/src \
    pytest -k 'not test_integration'
}

package() {
    cd "pydocstyle-${pkgver}"
    python -m installer --destdir="${pkgdir}/" dist/*.whl
    install -Dm644 LICENSE-MIT "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
